-- Cai dat cac cai nay truoc 
USE [master]
GO

EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1
GO

EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1
GO
sp_configure 'remote query timeout', 0 
go 
reconfigure with override 
go 
sp_configure 'show advanced options',1
reconfigure
sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
---Import
INSERT [Schemes] SELECT *
FROM OPENROWSET
( 'Microsoft.ACE.OLEDB.12.0', 
'Excel 8.0;Database=D:\PTTKHT_HDT\DKDA\my-project-quanlydoan\Database\Information.xls;;HDR=YES', 
'SELECT * FROM [Schemes$]')




c('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=D:\Documents and Settings\cv28.ITFAC.000\Desktop\Student.xls;;HDR=YES', 
'SELECT * FROM [Student$]')

SELECT * 
INTO Students
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
                'Excel 8.0;Database=D:\Documents and Settings\cv28.ITFAC.000\Desktop\Student.xls;IMEX=1',
                'SELECT * FROM [Student$]')
select * from Student


INSERT Student SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
                'Excel 8.0;Database=D:\Documents and Settings\cv28.ITFAC.000\Desktop\Student.xls;IMEX=1',
                'SELECT * FROM [Student$]')

 insert into OPENROWSET(
	'Microsoft.Jet.OLEDB.4.0', 
	'Excel 8.0;Database=D:\Documents and Settings\cv28.ITFAC.000\Desktop\Student.xls;;HDR=YES', 
	'SELECT * FROM [Student$]')
select * from Student ;

 INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=D:\Documents and Settings\cv28.ITFAC.000\Desktop\Student.xls
;IMEX=1','SELECT * FROM [Student$]')   
select * from Student ;

select * from Student
 INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
                'Excel 8.0;Database=D:\Documents and Settings\cv28.ITFAC.000\Desktop\Student.xls;IMEX=1',
                'SELECT * FROM [Student$]')    
 select * from Student